import type { UsersLoginParams, UsersLoginData } from '@/api/types/login/login';
import type { SignParams, SignData } from '@/api/types/sign/index';
import { API_ENUM, API_CONFIG } from './api';
import { hocksApi } from '@/api/utils/apiProcessingHocks';
import type { AxiosResponse } from 'axios';

// 登录 /api/user/login
const userLoginApi = (params: UsersLoginParams) => {
  return hocksApi(API_CONFIG[API_ENUM.USER_LOGIN], params, (response: AxiosResponse<any>): UsersLoginData => {
    return response.data as UsersLoginData;
  }).post();
};

// 注册
const registrationApi = (params: SignParams) => {
  return hocksApi(API_CONFIG[API_ENUM.USER_REGISTRATION], params, (response: AxiosResponse<any>): SignData => {
    return response.data as SignData;
  }).post();
};

export { userLoginApi, registrationApi };
